import { AtTabBar } from 'taro-ui'
import Taro from '@tarojs/taro'
import {Component} from "react"
import { BASEURL } from '../../constants/global'
import {View} from "@tarojs/components";

export default class  tabBar extends Component{
  constructor () {
    super(...arguments)
    this.state = {
    }
  }
  handleClick (value) {
    switch (value) {
      case 0:
        Taro.reLaunch({
          url: '/pages/index/index'
        });
        break;

      case 1:
        Taro.reLaunch({
          url: '/pages/host/hostIndex'
        });
        break;

      case 2:
        Taro.navigateTo({
          url: '/pages/person/healthimf'
        });
        break;
        // if(this.state.openid){
        //   const {itemcode} = this.state;
        //   Taro.navigateTo({
        //     url: `/pages/myRecord/healthRecords?itemcode=${itemcode}`
        //   });
        // }else{
        //   Taro.navigateTo({
        //     url: '/pages/myRecord/wxLogin'
        //   })
        // }
        // break;
      case 3:
        Taro.reLaunch({
          url: '/pages/person/index'
        });
        break;
      default:
        break;
    }
  }
  render () {
    return (
      <View>
        <View style={{'height':'4rem'}}></View>
      <AtTabBar
        fixed
        tabList={[
          { title: '首页', image: `${BASEURL}home.png`, selectedImage: `${BASEURL}homeSelected.png` },
          { title: '今日热点', image: `${BASEURL}knowledge.png`, selectedImage: `${BASEURL}knowledgeSelected.png` },
          { title: '健康档案', image: `${BASEURL}health.png`, selectedImage: `${BASEURL}healthSelected.png` },
          { title: '我的', image: `${BASEURL}self.png`, selectedImage:`${BASEURL}selfSelected.png` }
        ]}
        onClick={this.handleClick.bind(this)}
        current={this.props.tabBarCurrent}
      />
      </View>
    )
  }
}
